<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.hcz.entity.User" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <script type="text/javascript" src = "js/jquery.js"></script>
    <title>冻结用户</title>
    <style type="text/css">
    	span{
    		color:red;
    	}
    </style>
  </head>
  
  <body>
  <h3>可用的用户：</h3>
  <%
  	List<User> list = (List<User>)application.getAttribute("userList");
   %>
   <table border="1px"width="70%">
   	<tr>
   		
   		<td>用户名</td>
   		<td>用户状态</td>
   	</tr>
   	 <%for(User user:list){ 
   	 	if(user.isState()){
   	 %>
		 <tr>
	 	<td><%=user.getName() %></td>
	 	<td>
		 	  <%
		 		if(user.isState()){
		 	 %>
		 	 <span>可用</span>
		 	 <%} %>
	 	</td>
	 </tr>
   	<%} }%>
   </table>
   <hr>
   	<h3>冻结用户账户</h3>
   	<%
   	
   		String code = request.getParameter("p");
   		if("1001".equals(code)){
   	 %>
   	 <div style="color:red;">此用户不存在，请核实</div>
   	 <%}else if ("1002".equals(code)){ %>
   	 <div style="color:red;">修改失败</div>
   	 <%} %>
   <form action="account.jspx?p=close" method = "post" id = "myform">
   		用户名：<input type = "text" name = "username" id = "name"/><span id = "name_error"></span><br/>
   		状态：<input type = "text" name = "state" id = "state"/><span id = "state_error"></span><br/>
   		<input type = "button" value = "提交" id = "btn"/>
   </form>
   <script type="text/javascript">
   	$(document).ready(function(){
	  	
	  	 $("#name").keydown(function(){
	  		$("#name_error").html("");
	  	});
	  	$("#state").keydown(function(){
	  		$("#state_error").html("");
	  	});
  		$("#btn").click(function(){
  			
  			var name = $("#name").val();
  			var state = $("#state").val();
  			if(name.trim()==null || name.trim()=="" ){
  				$("#name").focus();
  				$("#name_error").html("请输入用户名：");
  				return ;
  			}
  			if(!state ){
  				$("#state").focus();
  				$("#state_error").html("请输入正确状态值：");
  				return ;
  			}
  			$("#myform").submit();
  		});
  	});
   </script>
  </body>
</html>
